import http from '@/utils/request'
//登录
function userLoginReq(userName, password) {
  return http({
    method: 'post',
    url: '/api/v1/auth/login',
    data: { userName, password },
  })
}
//注册
function userregReq(
  userName,
  password,
  age = '',
  avatar = '',
  area = '',
  address = '',
  nickName = '',
  gender = '',
  birthday = '2025/01/01',
) {
  return http({
    method: 'post',
    url: '/api/v1/auth/reg',
    data: { userName, password, birthday, age, avatar, area, address, nickName, gender },
  })
}
//文件上传
function fileUploadReq(file) {
  const formData = new FormData()
  formData.append('file', file)
  return http({
    method: 'post',
    url: '/api/v1/common/upload_file',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data: formData,
  })
}
// 修改用户信息
function userModifyReq(birthday, age, avatar, area, address, nickName, gender) {
  return http({
    method: 'put',
    url: '/api/v1/user/modify',
    data: { birthday, age, avatar, area, address, nickName, gender },
  })
}

// 修改密码
function userUpdatePwdReq(password, oldPassword) {
  return http({
    method: 'put',
    url: '/api/v1/user/update_pwd',
    data: { password, oldPassword },
  })
}
// 签到
function userCheckInReq() {
  return http({
    method: 'post',
    url: '/api/v1/user/check_in',
  })
}
// 获取用户信息
function getUserInfoReq() {
  return http({
    method: 'get',
    url: '/api/v1/user/info',
  })
}
export {
  userLoginReq,
  userregReq,
  userModifyReq,
  userUpdatePwdReq,
  userCheckInReq,
  getUserInfoReq,
  fileUploadReq,
}
